package com.lichuandi.entity;

import com.alibaba.fastjson.JSON;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;

import java.util.ArrayList;
import java.util.List;

public class TEST {
    public static void main(String[] args) throws JsonProcessingException {
        ObjectMapper mapper = new ObjectMapper();
        ObjectA objectA = new ObjectA();
        objectA.setSs("ccc");
        List<ObjectB> list = new ArrayList<>();
        objectA.setObjectB(list);
        String s = mapper.writeValueAsString(objectA);
        Object o = JSON.toJSON(objectA);
        System.out.println(o);
        System.out.println(s);
    }
}
class ObjectA {
    private String ss;
    private List<ObjectB> objectB;

    public ObjectA(String ss, List<ObjectB> objectB) {
        this.ss = ss;
        this.objectB = objectB;
    }

    public ObjectA() {

    }

    public String getSs() {
        return ss;
    }

    public void setSs(String ss) {
        this.ss = ss;
    }

    public List<ObjectB> getObjectB() {
        return objectB;
    }

    public void setObjectB(List<ObjectB> objectB) {
        this.objectB = objectB;
    }
}

class  ObjectB {
    private String name;
    private String age;

    public ObjectB(String name, String age) {
        this.name = name;
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getAge() {
        return age;
    }

    public void setAge(String age) {
        this.age = age;
    }
}
